//     https://ac.nowcoder.com/acm/problem/26226



#include <iostream>
using namespace std;

int main()
{
    int n;
    char ss;
    long long s = 0, h = 0, y = 0;
    cin >> n;
    while (n--)
    {
        cin >> ss;
        if (ss == 's') s++;
        else if (ss == 'h') h += s;
        else if (ss == 'y') y += h;
    }

    cout << y << endl;
    return 0;
}